<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="sample_project" default="build" basedir=".">
   <!--
      The <property> tag defines variables we 
      are using to store the path to different 
      files and tools required and input/output 
      directories. You use those variables by
      like this: ${variable}
   -->
   <property name="BUILD_DIR"      value="../build" />
   <property name="SOURCE_DIR"     value="../src" />

   <property name="GOOGLE_CLOSURE" value="compiler.jar" />
   <property name="JS_LINT" value="jslint4java-1.4.4.jar" />
    
    
  <taskdef name="jslint" classname="com.googlecode.jslint4java.ant.JSLintTask" classpath="${JS_LINT}" />
  <taskdef name="jscomp" classname="com.google.javascript.jscomp.ant.CompileTask" classpath="${GOOGLE_CLOSURE}"/>

    
  
    <target name="build" depends="clean, lint, bundle_javascript, compress_javascript" />
   
   
    <target name="lint">
        <jslint options="undef, eqeqeq, bitwise, newcap, immed, browser">
            <predef>jsMotif, window, ActiveXObject</predef>
            <formatter type="plain" />
            <fileset dir="${SOURCE_DIR}" includes="**/*.js" excludes="selector.js"/>
        </jslint>
    </target>
        
       
   <target name="bundle_javascript">
     
      <echo>Bundle JavaScript Files...</echo>
 
      <!-- core.js: all the core project related code -->
      <concat destfile="${BUILD_DIR}/jsMotif.js">
         <filelist dir="${SOURCE_DIR}">
            <file name="license.js" />
            <file name="namespace.js" />
            <file name="dom.js" />
            <file name="comm/namespace.js" />
            <file name="comm/jsonparse.js" />
            <file name="comm/xhttp.js" />
            <file name="comm/jsonp.js" />
            <file name="errors.js" />
            <file name="selector.js" />
            <file name="Template.js" />
            <file name="TemplateJson.js" />
         </filelist>
      </concat>
      <echo>JavaScript Bundles Done!!!</echo>
   </target>
    
  
   <target name="compress_javascript" depends="bundle_javascript">
      <echo>Compressing JavaScript Files...</echo>
      <jscomp compilationLevel="simple" warning="verbose" debug="false" output="${BUILD_DIR}/jsMotif.min-tmp.js">
        <sources dir="${BUILD_DIR}">
            <file name="jsMotif.js"/>
        </sources>
      </jscomp>
      <echo>JavaScript Compression Done!!!</echo>
      <concat destfile="${BUILD_DIR}/jsMotif.min.js">
          <filelist>
            <file name="${SOURCE_DIR}/license.js" />
            <file name="${BUILD_DIR}/jsMotif.min-tmp.js" />
         </filelist>
      </concat>
      <echo>License disclaimer added!!!</echo>
      <delete file="${BUILD_DIR}/jsMotif.min-tmp.js"/>
   </target>
    
    
   <!--
      This task will clean out any previous build files by
      deleting the current build folder and re-creating it
   -->
   <target name="clean">
      <echo>clean build folder...</echo>
      <delete dir="${BUILD_DIR}/*"/>
      <echo>Create new build folder...</echo>
      <mkdir dir="${BUILD_DIR}"/>
   </target>
</project>